/*=+--+=#=+--     Unmanned Aerial System Management Software      --+=#=+--+=#*\
|          Copyright (C) 2011 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

            Jack Elston                       Cory Dixon                        
|           elstonj@colorado.edu              dixonc@colorado.edu              |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/

/*!
  \file  DHL Translator
	\brief DHL Translator header file
*/

#ifndef __DHLTRANTHREAD_H
#define __DHLTRANTHREAD_H

#include <unistd.h>
#include <signal.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>

#include "String.h"
#include "command.h"
#include "zigbee.h"
#include "queue.h"
#include "type_defs.h"
#include "threadedPipe.h"
#include "shmStruct.h"

#define NETUAS_MS
#include "dhl_packet.h"

#define WPs_PER_PACKET  7
#define BYTES_PER_WP    13
#define ADDR_REQ_PERIOD 2

#define SPACING         (1)

class DHL : public ThreadedPipe
{
private:
  void setAddress(uint16_t xb_addr);
  void translate();

  uint16_t my_addr;
  bool xb_init;
  cu_uchar_t seq_num;
  ZigbeeQueue xbQueue;

  TimeStamp last_addr_req;
  bool first_time_subscriber;

public:
  DHL(String name);
  ~DHL() {}

  void sendLEDCommand(char cmd);
					 
  void update();
};

#endif
